
const state = {
  tabList: [],
  rankSong: []
}

const actions = {
  // 获取排行榜数据
  async getTabList({ commit }) {
    const res = await this._vm.$API.rank.reqGetRankList()
    commit('SAVE_TABLIST', res.data.slice(0, 3))
  },
  // 获取排行榜歌曲
  async getRankSong({ commit }, data) {
    let { bandId, pn, rn } = data
    pn = pn || 1
    rn = rn || 30
    const res = await this._vm.$API.rank.reqGetRankSong(bandId, pn, rn)
    commit('SAVE_RANK_SONG', res.data.musicList)
  }
}

const mutations = {
  // 存储排行榜数据
  SAVE_TABLIST(state, value) {
    state.tabList = value
  },
  // 存储排行榜歌曲
  SAVE_RANK_SONG(state, value) {
    state.rankSong = value
  }
}

const getters = {}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters
}
